﻿using System;
using System.Web;
using System.Web.Routing;

namespace BlueSky.Web.Routing
{
    public class NotEqualConstraint : IRouteConstraint
    {
        protected string _match = String.Empty;

        public NotEqualConstraint(string match)
        {
            _match = match;
        }

        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            if (values[parameterName] != null)
            {
                String sValue = values[parameterName].ToString();
                return String.Compare(sValue, _match, true) != 0;
            }
            return false;
        }
    }
}
